package com.tsingteng.cosfun.ui.message.comment;

import com.tsingteng.cosfun.bean.CenterThreeNotification;
import com.tsingteng.cosfun.bean.PlayDetailsBean;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;
import com.tsingteng.cosfun.ui.message.comment.model.OtherModel;

/**
 * 描述 :
 * 创建人: 肖利.
 * 时间:2018/8/6
 * qq(872179966)
 */

public class OtherPresenter extends BasePresenter<OtherContract.ITherView> implements OtherContract.IOtherPresenter{

    private OtherModel otherModel;
    private OtherContract.ITherView view;
    public OtherPresenter(){
        otherModel = new OtherModel();
    }
    @Override
    public void loginOfficalNotification(String other_type, int page) {
        view = getView();
        RxObserver<CenterThreeNotification> rxObserver = new RxObserver<CenterThreeNotification>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(CenterThreeNotification notificationBean) {
                view.getOtherData(notificationBean);
            }
        };

        otherModel.getOfficalNotification(other_type,page,rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void loginReadCount(String funType, int maxid) {
        view = getView();
        RxObserver<Integer> rxObserver = new RxObserver<Integer>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(Integer integer) {
                view.getReadCountResult(integer);
            }
        };
        otherModel.getIsRead(funType,maxid,rxObserver);
        addDisposable(rxObserver);
    }
    @Override
    public void getPlayDetailData(String paragraphId) {
        view = getView();
        RxObserver<PlayDetailsBean> rxObserver = new RxObserver<PlayDetailsBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
                view.showFail(errorMsg);
            }

            @Override
            protected void onSuccess(PlayDetailsBean playDetailsBean) {
                view.showOtherDetailsData(playDetailsBean);
            }
        };

        otherModel.getPlayDetails(paragraphId,rxObserver);
        addDisposable(rxObserver);
    }
}
